﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Threading;
using System.IO;
using SPThumbnailExtender.Interne;

namespace SPThumbnailExtender
{
    namespace Handler
    {

        public class MobileHTMLHandler : IHttpHandler
        {
            public bool IsReusable
            {
                get { return false; }
            }


            public void ProcessRequest(HttpContext context)
            {
                //write your handler implementation here.
                string strHtml = context.Request.QueryString["Html"];
                string strWidth = context.Request.QueryString["width"];
                string strHeight = context.Request.QueryString["height"];
                string strCount = context.Request.QueryString["count"];
                
                int? _imgWidth = null;
                int? _imgHeight = null;
                bool? _bCount = null;
                bool? _bCache = null;
                int imgWidth;
                if (int.TryParse(strWidth, out imgWidth))
                {
                    _imgWidth = imgWidth;
                }
                int imgHeight;
                if (int.TryParse(strHeight, out imgHeight))
                {
                    _imgHeight = imgHeight;
                }
                int _iPage = 0;

                bool bCache;
                if (bool.TryParse(context.Request["usecache"], out bCache))
                {
                    _bCache = bCache;
                }

                bool bCount;
                if (bool.TryParse(strCount, out bCount))
                {
                    _bCount = bCount;
                }
                HandlerHelper.ProcessRequest(context, strHtml, _imgWidth, _imgHeight, _iPage, _bCount, _bCache, typeof(ThumbnailHtml));
            }
        }
    }
}